
cd "/Users/eliemurard/Dropbox/WorldBank Refugee project/World Dev revision/replication/"





* Packahe that need to be installed 	
*ssc instal outreg
*ssc instal  reghdfe
	
use census1928_provincelevel,clear


	g coh1215 = inrange(cohort,1912,1915)
	g coh1617 = inrange(cohort,1916,1917)
	g coh1215_ref=  ref*coh1215
	g coh1617_ref=  ref*coh1617 
	g ref_highinvest =   high_schoolsupply*ref
	g coh1617_ref_highinvest =  high_schoolsupply*ref*coh1617
	g coh1215_ref_highinvest =  high_schoolsupply*ref*coh1215 

	egen prov_coh_FE= group(cohort province1928)
	
	label var literacy  "Literacy"
	label var ref "Refugee" 
	label var coh1215_ref "Refugee* Cohort 1912-1915"  
	label var coh1617_ref "Refugee* Cohort 1916-1917"   
	label var ref_highinvest  "Refugee* Province with High School Supply"
	label var coh1617_ref_highinvest "Refugee* Cohort 1912-1915 * Province with High School Supply"  
	label var coh1215_ref_highinvest  "Refugee* Cohort 1916-1917 * Province with High School Supply"   
	
	
	
	global option varlabels tex plain fragment bdec(3) se starloc(1) starlevels(10 5 1) nocenter 

	global treat  ref coh1215_ref coh1617_ref 
	global interaction  ref coh1215_ref coh1617_ref ref_highinvest  coh1617_ref_highinvest coh1215_ref_highinvest 
	

	
* Table 1: The role of school supply in driving refugees' educational integration
	
	outreg,clear(base)
		
		tempvar y 
	    g  `y' = literacy 
		local laa: variable label `y'
		qui su  `y'     
		local av: di %4.3f  r(mean)
	    qui   reghdfe  `y' $treat      , absorb(prov_coh_FE) 
		outreg, merge(base)  ${option}  keep($treat ) nod  ctitle("`laa'", "")  addrows( "Province and Cohort FE", "Y" \ "Average outcome", `av' ) 
		qui   reghdfe  `y' $interaction      , absorb(prov_coh_FE) 
		outreg, merge(base)  ${option}  keep($interaction ) nod  ctitle("`laa'", "")  addrows( "Province and Cohort FE", "Y" \ "Average outcome", `av' ) 

	   
		outreg , replace replay(base)    ${option}
  
	

* Figure 2: Refugee-native literacy gap in 1928 (for males), by level of school supply increase
	
	g se_= literacy
	collapse (mean) literacy   (semean) se_ [fw=pop_] , by(cohort high_schoolsupply ref )		
	reshape wide  literacy  se_  , i(high_schoolsupply  cohort ) j(ref) 

	g gap=  literacy1 - literacy0 
	g segap=sqrt( se_1^2 + se_0^2) 
	
	g gap_up   = gap + 1.96* segap
	g gap_low =gap - 1.96* segap
	
	twoway  (rarea  gap_up gap_low  cohort   if  high_schoolsupply ==1, color(ltblue)) ///
			(line  gap   cohort              if  high_schoolsupply ==1 , lpattern(dash) lcolor(blue) sort) ///
			(rarea  gap_up gap_low  cohort   if  high_schoolsupply ==0, color(" 189 30 36*.1") ) ///
			(line gap    cohort              if high_schoolsupply ==0  , lpattern(solid) lcolor(red)    sort) /// 
			,  xtitle("Birth cohort", size(medsmall))  ///
			legend( col(1) ring(0) pos(10) si(medsmall) ///
			order(2 "High increase in school supply"  4 "Low increase in school supply" )) ///
			xlabel(1908(1)1917)	 ylab(, angle(horizontal)) graphregion(color(white))  

			

			
	
	